<template>
  <footer class="footer">
    <span class="todo-count">
      剩余<strong>{{ showArr.length }}</strong>
    </span>
    <ul class="filters">
      <li>
        <a
          :class="{ selected: getSel === 'all' }"
          href="javascript:;"
          @click="clickAll"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: getSel === 'no' }"
          href="javascript:;"
          @click="clickNo"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: getSel === 'yes' }"
          href="javascript:;"
          @click="clickYes"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clearFn()">清除已完成</button>
  </footer>
</template>

<script>
import { mapState, mapGetters, mapMutations } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState(["list", "getSel"]),
    ...mapGetters(["showArr"]),
  },
  methods: {
    ...mapMutations(["clickFn", "clear"]),
    clickAll() {
      this.clickFn("all");
    },
    clickNo() {
      this.clickFn("no");
    },
    clickYes() {
      this.clickFn("yes");
    },
    clearFn() {
      this.clear("clear");
    },
  },
};
</script>